ASP 连接数据库问题`

来源:百度知道 编辑:UC知道 时间:2024/05/29 14:36:07
<%
do while not rs.eof
%>
<%=rs("Id")%>|
<%
exec_Youxi="select * from Data ID = " &rs("A4")& " "
set rs_Youxi=server.createobject("adodb.recordset")
rs_Youxi.open exec_Youxi,conn,1,1
%>
<%=rs_Youxi("A1")%>
|-<%=rs("A3")%>-<%=rs("A4")%><br />
<%
rs.movenext
rs_Youxi.movenext
loop
%>

我的目的是想让 exec_Youxi="select * from Data ID = " &rs("A4")& " " 这一段的 ID = <%=rs("A4")%>

where ID = " &rs("A4")& " "

这样写就能行了

<%
do while not rs.eof
%>
<%=rs("Id")%>|
<%
exec_Youxi="select * from Data where ID = " &rs("A4")& " "
set rs_Youxi=server.createobject("adodb.recordset")
rs_Youxi.open exec_Youxi,conn,1,1
do while not rs_Youxi.eof

%>
<%=rs_Youxi("A1")%>
|-<%=rs("A3")%>-<%=rs("A4")%><br />
<%
rs_Youxi.movenext
loop

rs.movenext

loop
%>

你这是要显示 下级分类吧,写个递归多好呢。
<%
rs_Youxi.movenext
rs.movenext
loop
%>
这弄反了。。粗心造成的

exec_Youxi="select * from Data ID = " &rs("A4")& " "
漏了个where

exec_Youxi="select * from Data where ID = " &rs("A4")& " "